package com.lightsh.body;

import org.jbox2d.common.Vec2;
import org.jbox2d.dynamics.World;

import com.lightsh.gui.PhysicsScreen;

public class PolygonImpl extends Polygon{
	protected final PhysicsScreen mParentScreen;
	/**
	 * 创建一个多边形，顶点添加顺序为顺时针依次添加
	 * <br/>注意: 该类使用的单位为px
	 * @param screen	该body所属的screen
	 * @param x 该图形的坐标原点x，作为之后{@link #add(Vec2, boolean)}的参考坐标
	 * @param y 该图形的坐标原点y，作为之后{@link #add(Vec2, boolean)}的参考坐标
	 * @param density 密度
	 * @param friction 摩擦力
	 * @param restitution 碰撞后恢复系数
	 */
	public PolygonImpl(PhysicsScreen screen, float x, float y,
			float density, float friction, float restitution) {
		super(screen.getWorld(), screen.pxToMeter(x), screen.pxToMeter(y), density, friction, restitution);
		mParentScreen = screen;
	}
	
	@Override
	public void add(Vec2 vec2, boolean bLast) {
		vec2.x = mParentScreen.pxToMeter(vec2.x);
		vec2.y = mParentScreen.pxToMeter(vec2.y);
		super.add(vec2, bLast);
	}

	
}
